package cn.geminis.warehouse.service.purchase.entity.repository;

import jakarta.transaction.Transactional;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.time.LocalDate;

public interface PurchaseRepository {

    @Modifying
    @Transactional(rollbackOn = Exception.class)
    @Query("update Purchase p set p.deliveryTime = ?1, p.state = 20 where p.id in ?2")
    int delivery(LocalDate deliveryTime, String[] ids);

    @Modifying
    @Transactional(rollbackOn = Exception.class)
    @Query("update Purchase p set p.arriveTime = ?1, p.state = 30 where p.id in ?2")
    int arrive(LocalDate arriveTime, String[] ids);

    @Modifying
    @Transactional(rollbackOn = Exception.class)
    @Query("update Purchase p set p.receiveTime = ?1, p.state = 40 where p.id in ?2")
    int receive(LocalDate arriveTime, String[] ids);

    @Modifying
    @Transactional(rollbackOn = Exception.class)
    @Query("update Purchase p set p.packageTime = ?1, p.state = 60 where p.id in ?2")
    int pack(LocalDate arriveTime, String[] ids);

}
